﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleNetwork
{
    public enum PokemonIndex : int
    {
        Pokemon1OfTeam1 = 2146817333,
        Pokemon2OfTeam1 = 994235701,
        Pokemon1OfTeam2 = 580733392,
        Pokemon2OfTeam2 = -571848240,
        WrongInput = -1
    }
    public static class PokemonIndexHelper
    {
        public static PokemonIndex ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }

        public static PokemonIndex Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(PokemonIndex)))
            {
                if (value == val) return (PokemonIndex)value;
            }
            return PokemonIndex.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, PokemonIndex value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
